package com.coda.mapper;

import com.coda.entity.CityInfo;
import com.coda.entity.DistrictInfo;
import com.coda.entity.ProvinceInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RegionInfoMapper {
    /**
     * 查询省份信息列表
     * @return
     */
    @Select("select * from province_info")
    List<ProvinceInfo> getProvinceList();

    /**
     * 根据省份id查询城市信息
     * @param id
     * @return
     */
    @Select("select * from city_info where province_id = #{id}")
    List<CityInfo> getCityList(Long id);

    /**
     * 根据城市id查询区县信息
     * @param id
     * @return
     */
    @Select("select * from district_info where city_id = #{id}")
    List<DistrictInfo> getDistrictList(Long id);

    /**
     * 根据id获取县城信息
     * @param cityId
     * @return
     */
    @Select("select * from city_info where id = #{cityId}")
    CityInfo getCity(Long cityId);

    /**
     * 根据id获取城市信息
     * @param districtId
     * @return
     */
    @Select("select * from district_info where id = #{districtId}")
    DistrictInfo getDistrict(Long districtId);

    /**
     *
     * @param provinceId
     * @return
     */
    @Select("select * from province_info where id = #{provinceId}")
    ProvinceInfo getProvince(Long provinceId);


}
